/*   time:2019-06-13 20:39:24*/
var e = getApp(),
    t = e.requirejs("core"),
    a = e.requirejs("wxParse/wxParse"),
    i = e.requirejs("biz/diypage"),
    s = e.requirejs("jquery");
Page({
    data: {
        route: "member",
        icons: e.requirejs("icons"),
        member: {},
        diypages: {},
        audios: {},
        audiosObj: {},
        modelShow: !1,
        autoplay: !0,
        interval: 5e3,
        duration: 500,
        swiperheight: 0,
        iscycelbuy: !1,
        bargain: !1,
        result: {}
    },
    onLoad: function(t) {
        e.checkAuth(), this.setData({
            options: t
        })
    },
    getInfo: function() {
        var i = this;
        t.get("member", {}, function(e) {
            1 == e.isblack && wx.showModal({
                title: "无法访问",
                content: "您在商城的黑名单中，无权访问！",
                success: function(e) {
                    e.confirm && i.close(), e.cancel && i.close()
                }
            }), 0 != e.error ? wx.redirectTo({
                url: "/pages/message/auth/index"
            }) : i.setData({
                member: e,
                show: !0,
                customer: e.customer,
                customercolor: e.customercolor || "",
                phone: e.phone,
                phonecolor: e.phonecolor || "",
                phonenumber: e.phonenumber || "",
                iscycelbuy: e.iscycelbuy,
                bargain: e.bargain
            }), a.wxParse("wxParseData", "html", e.copyright, i, "5")
        })
    },
    onShow: function() {
        e.checkAuth();
        var a = this;
        this.getInfo(), wx.getSystemInfo({
            success: function(e) {
                var t = e.windowWidth / 1.7;
                a.setData({
                    windowWidth: e.windowWidth,
                    windowHeight: e.windowHeight,
                    swiperheight: t
                })
            }
        }), a.setData({
            imgUrl: e.globalData.approot
        }), i.get(this, "member", function(e) {})
    },
    onShareAppMessage: function() {
        return t.onShareAppMessage()
    },
    imagesHeight: function(e) {
        var t = e.detail.width,
            a = e.detail.height,
            i = e.target.dataset.type,
            s = this;
        wx.getSystemInfo({
            success: function(e) {
                s.data.result[i] = e.windowWidth / t * a, (!s.data[i] || s.data[i] && result[i] < s.data[i]) && s.setData({
                    result: s.data.result
                })
            }
        })
    },
    cancelclick: function() {
        wx.switchTab({
            url: "/pages/index/index"
        })
    },
    confirmclick: function() {
        wx.openSetting({
            success: function(e) {}
        })
    },
    phone: function() {
        var e = this.data.phonenumber + "";
        wx.makePhoneCall({
            phoneNumber: e
        })
    },
    play: function(e) {
        var o = e.target.dataset.id,
            u = this.data.audiosObj[o] || !1;
        if (!u) {
            u = wx.createInnerAudioContext("audio_" + o);
            var t = this.data.audiosObj;
            t[o] = u, this.setData({
                audiosObj: t
            })
        }
        var c = this;
        u.onPlay(function() {
            var n = setInterval(function() {
                var e = u.currentTime / u.duration * 100 + "%",
                    t = Math.floor(Math.ceil(u.currentTime) / 60),
                    a = (Math.ceil(u.currentTime) % 60 / 100).toFixed(2).slice(-2),
                    i = Math.ceil(u.currentTime);
                t < 10 && (t = "0" + t);
                var s = t + ":" + a,
                    r = c.data.audios;
                r[o].audiowidth = e, r[o].Time = n, r[o].audiotime = s, r[o].seconds = i, c.setData({
                    audios: r
                })
            }, 1e3)
        });
        var a = e.currentTarget.dataset.audio,
            i = e.currentTarget.dataset.time,
            s = e.currentTarget.dataset.pausestop,
            r = e.currentTarget.dataset.loopplay;
        0 == r && u.onEnded(function(e) {
            n[o].status = !1, c.setData({
                audios: n
            })
        });
        var n = c.data.audios;
        n[o] || (n[o] = {}), u.paused && 0 == i ? (u.src = a, u.play(), 1 == r && (u.loop = !0), n[o].status = !0, c.pauseOther(o)) : u.paused && 0 < i ? (u.play(), 0 == s ? u.seek(i) : u.seek(0), n[o].status = !0, c.pauseOther(o)) : (u.pause(), n[o].status = !1), c.setData({
            audios: n
        })
    },
    pauseOther: function(i) {
        var r = this;
        s.each(this.data.audiosObj, function(e, t) {
            if (e != i) {
                t.pause();
                var a = r.data.audios;
                a[e] && (a[e].status = !1, r.setData({
                    audios: a
                }))
            }
        })
    },
    onHide: function() {
        this.pauseOther()
    },
    onUnload: function() {
        this.pauseOther()
    },
    navigate: function(e) {
        var t = e.currentTarget.dataset.url,
            a = e.currentTarget.dataset.phone,
            i = e.currentTarget.dataset.appid,
            s = e.currentTarget.dataset.appurl;
        t && wx.navigateTo({
            url: t,
            fail: function() {
                wx.switchTab({
                    url: t
                })
            }
        }), a && wx.makePhoneCall({
            phoneNumber: a
        }), i && wx.navigateToMiniProgram({
            appId: i,
            path: s
        })
    },
    close: function() {
        e.globalDataClose.flag = !0, wx.reLaunch({
            url: "/pages/index/index"
        })
    }
});